package com.hiof.overlays;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.hiof.R;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.Overlay;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.net.wifi.WifiConfiguration.Status;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.LinearLayout;

public class OverlayController {
	Context context;
	List<Overlay> overlays = new ArrayList<Overlay>();
	MapView mapView;
	TeammatePositionOverlay teamatePositionOverlay;
	TripRouteOverlay tripRouteOverlay;
	MyLocationOverlay myLocationOverlay;

	public OverlayController(Context context, MapView mapView) {
		this.context = context;
		this.mapView = mapView;
		initOverlays();
	}
	
	private void initOverlays() {
//		initTripRouteOverlay();
		initMyLocationOverLay();
//		initHotspotsOverlay();
	}


	public void initMyLocationOverLay() {
		Log.d("mapview","mapview:"+String.valueOf(mapView));
		myLocationOverlay = new MyLocationOverlay(context, mapView);
		myLocationOverlay.enableMyLocation();
		myLocationOverlay.enableCompass();
		overlays.add(myLocationOverlay);
	}



	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

	public List<Overlay> getOverlays() {
		return overlays;
	}

	public void setOverlays(List<Overlay> overlays) {
		this.overlays = overlays;
	}

	public MapView getMapView() {
		return mapView;
	}

	public void setMapView(MapView mapView) {
		this.mapView = mapView;
	}

	public TeammatePositionOverlay getTeamatePositionOverlay() {
		return teamatePositionOverlay;
	}

	public void setTeamatePositionOverlay(
			TeammatePositionOverlay teamatePositionOverlay) {
		this.teamatePositionOverlay = teamatePositionOverlay;
	}



	public TripRouteOverlay getTripRouteOverlay() {
		return tripRouteOverlay;
	}

	public void setTripRouteOverlay(TripRouteOverlay tripRouteOverlay) {
		this.tripRouteOverlay = tripRouteOverlay;
	}

	public MyLocationOverlay getMyLocationOverlay() {
		return myLocationOverlay;
	}

	public void setMyLocationOverlay(MyLocationOverlay myLocationOverlay) {
		this.myLocationOverlay = myLocationOverlay;
	}

	private void init() {
		mapView = (MapView) ((MapActivity) context).findViewById(R.id.mapview);
		overlays = mapView.getOverlays();
	}

//	public void drawTeamatePositionOverlay(Location location,
//			LinkedList<UserInfo> teammatesInfo) {
//		overlays.remove(teamatePositionOverlay);
//		teamatePositionOverlay = new TeammatePositionOverlay(
//				context.getResources(), location, teammatesInfo);
//		overlays.add(teamatePositionOverlay);
//	}

//	public void initTripRouteOverlay() {
//		RouteTask task = new RouteTask();
//		task.execute(context);
//	}
}
